package org.xxgc.qiuqiu.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

//长连接配置表
@Configuration
@EnableWebSocketMessageBroker
public class WebScoketConfig implements WebSocketMessageBrokerConfigurer {
    @Override
    public void configureMessageBroker(MessageBrokerRegistry registry) {
//        启动简单消息代理,请阅消息开头必须是/game
        registry.enableSimpleBroker("/game");

//        发送消息的开头
        registry.setApplicationDestinationPrefixes("/qiuqiu");
    }

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        //註冊/ws端點
        registry.addEndpoint("/ws").withSockJS();
    }
}
